﻿using AutoMapper;
using DFGK.IRepository;
using DFGK.IService;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK.Service
{
    public class NetworkAddressService : BaseService, INetworkAddressService
    {
        private readonly INetworkAddressRepository _networkAddressRepository;
        private readonly IUnitOfWork _unitOfWork;
        public NetworkAddressService(IMapper mapper, INetworkAddressRepository _networkAddressRepository, IUnitOfWork _unitOfWork) : base(mapper)
        {
            this._networkAddressRepository = _networkAddressRepository;
            this._unitOfWork = _unitOfWork;
        }


        public List<NetworkAddress> GetNetworkAddress(string? netAddress, int pageIndex, int pageSize, out int totalCount)
        {
            var custList = _networkAddressRepository.GetEntityAlls();
            if (!string.IsNullOrEmpty(netAddress))
            {
                custList = custList.Where(c => c.NetAddress.Contains(netAddress));
            }
            var list = _networkAddressRepository.GetEntityAlls(custList, pageIndex, pageSize, out totalCount, x => x.CreateDate, false);
            return list.ToList();
        }

        public List<NetworkAddress> GetNetMsgDown()
        {
            var list = _networkAddressRepository.GetAllEntityList();
            return list;
        }
    }
}
